package com.ecfront.dao.impl;

import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.LockMode;
import org.springframework.context.ApplicationContext;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.ecfront.dao.NoteDAO;
import com.ecfront.pojo.Note;


/**
 * @version 1.0
 * @author www.ecfrom.com
 */

public class NoteDAOImpl extends HibernateDaoSupport implements NoteDAO {

	protected void initDao() {}


	public void save(Note transientInstance) {
		getHibernateTemplate().saveOrUpdate(transientInstance);
	}

	public void delete(Note persistentInstance) {
		getHibernateTemplate().delete(persistentInstance);
	}

	public Note findById(java.lang.Integer id) {
		Note instance = (Note) getHibernateTemplate().get(
					"com.ecfront.pojo.Note", id);
		return instance;
	}

	public List findByProperty(String propertyName, Object value) {
		String queryString = "from Note as model where model."
					+ propertyName + "= ?";
		return getHibernateTemplate().find(queryString, value);
	}

	public List findByNtitle(Object ntitle) {
		return findByProperty(NTITLE, ntitle);
	}

	public List findByNcontent(Object ncontent) {
		return findByProperty(NCONTENT, ncontent);
	}

	public List findAll() {
		String queryString = "from Note";
		return getHibernateTemplate().find(queryString);
	}

	public static NoteDAO getFromApplicationContext(ApplicationContext ctx) {
		return (NoteDAO) ctx.getBean("NoteDAO");
	}
}